package com.example.demo.his.leetcode;

/**
 * @auther zzc
 * @date 2021/3/23 11:57
 */
public class 二叉树的最大深度 {

    public static void main(String[] args) {
        TreeNode treeNode = new TreeNode();
        int treeHeight = getTreeHeight(treeNode);
        System.out.println(treeHeight);
    }

    private static int getTreeHeight(TreeNode root) {
        return root == null ? 1 : 1 + Math.max(getTreeHeight(root.left), getTreeHeight(root.right));
    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        public TreeNode() {
        }

        public TreeNode(int val) {
            this.val = val;
        }

        public TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }


    }
}
